package LinkList;

public class LinkedList01 {
    public static class ListNode{
        private int val;
        private ListNode prev;
        private ListNode next;

        public ListNode(int val){
            this.val = val;
        }
    }

    public ListNode head;
    public ListNode last;


    //返回链表的长度
    public int length(){
        ListNode cur = head;
        int count = 0;
        while(cur != null){
            cur = cur.next;
            count++;
        }
        return count;
    }

    //展示链表的元素
    public void display() {
        ListNode cur = head;
        while (cur != null) {
            System.out.println(cur.val + " ");
            cur = cur.next;
        }
        System.out.println();
    }

    //判断是否包含关键字Key在里面
    public boolean contains(int key){
        ListNode cur = head;
        while(cur != null){
            if(cur.val == key){
                return true;
            }
        }
        return false;
    }

    //头插法
    public void addFirst(int val){

    }

    //尾插法
    public void addLast(int val){

    }

    //任意位置插入元素
    public void insert(int index, int data){

    }

    //删除第一次出现的关键字Key
    public void remove(int key){

    }

    //删除所有值为Key的节点
    public void remoeKey(int key){

    }


    //清空链表的元素
    public void clear(){

    }




}
